package com.slz3.business.module.memberManagement.memShoppingCar.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;

import java.time.LocalDateTime;

public class MemShoppingCarFactory {

    /**
     * 初始化基础属性值
     */
    public static MemShoppingCar initBaseFields(MemShoppingCar memShoppingCar) {
        if (memShoppingCar.getUuid() == null) {
            memShoppingCar.setUuid(UUIDUtils.generateUUID());
            memShoppingCar.setCreateTime(LocalDateTime.now());
            if (VE.isEmpty(memShoppingCar.getSerAudit())) {
                memShoppingCar.setSerAudit(AuditFlag.WAIT_SUBMIT);
            }
            if (VE.isEmpty(memShoppingCar.getSerUsing())) {
                memShoppingCar.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            memShoppingCar.setLastModifyTime(LocalDateTime.now());
        }
        return memShoppingCar;
    }

    /**
     * 初始化基础属性值
     */
    public static MemShoppingCar initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static MemShoppingCar newTemStyle() {
        return new MemShoppingCar();
    }

}
